<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学习首页</title>
    <link rel="stylesheet" href="__STATIC__/index/css/index.css">
    <script src="__STATIC__/index/js/jquery.min.js"></script>
    <style>
        img{width:50px;}
    </style>
</head>
<body>
    <div id="main">
        <div class="navlist">
            <ul>
                <li><a href="">nav1</a></li>
                <li><a href="">nav2</a></li>
                <li><a href="">nav3</a></li>
                <li><a href="">nav4</a></li>
                <li><a href="">nav5</a></li>
                <li><a href="">nav6</a></li>
            </ul>
        </div>
        <div class="content">
            <div class="mainCont">
                <form action="{:url('index/fileUpload')}" enctype="multipart/form-data" method="post">
                    <input type="file" name="file">
                    <input type="submit" value="submit">
                </form>
            </div>
            <div class="sidebar"></div>
        </div>

        <table style="color:#333;text-align: center;">
            <tr>
                <th width="15px">id</th>
                <th width="100px">图片</th>
                <th width="50px">操作</th>
            </tr>
            {volist name="file_result" id="vo"}
                <tr>
                    <td>{$vo.id}</td>
                    <td><img src="/uploads/{$vo.file}" alt=""></td>
                    <td>
                        <a href="javascript:void(0);" id="{$vo.id}" class="del" >删除</a>
                    </td>
                </tr>
            {/volist}
        </table>
        {$page}
        <br />
        <table style="color:#333;text-align: center;">
            <tr>
                <th width="15px">id</th>
                <th width="100px">图片</th>
                <th width="50px">操作</th>
            </tr>
            {volist name="file_del" id="vo"}
            <tr>
                <td>{$vo.id}</td>
                <td><img src="/uploads/{$vo.file}" alt=""></td>
                <td>
                    <a href="javascript:void(0);" id="{$vo.id}" class="restore" >恢复</a>
                </td>
            </tr>
            {/volist}
        </table>
        {$file_del_page}
    </div>

    <script>
        $(".del").click(function(){
            var id = $(this).attr('id');
            console.log(id);
            $.ajax({
                    type: 'post',
                    dataType: "json",
                    data:{id:id},
                    url:"{:url('index/deleteFile')}",
                    success:function(result) {
//                        console.log(result);
                        if(result.code == 1){
                            alert(result.msg);
                            window.location.href = result.url;
                        }else{
                            alert(result.msg);
                            console.log(result);
                        }
//
                }
            });
        });
        $(".restore").click(function(){
            var id = $(this).attr('id');
            console.log(id);
            $.ajax({
                type: 'post',
                dataType: "json",
                data:{id:id},
                url:"{:url('index/renew')}",
                success:function(result) {
//                        console.log(result);
                    if(result.code == 1){
                        alert(result.msg);
                        window.location.href = result.url;
                    }else{
                        alert(result.msg);
                        console.log(result);
                    }
//
                }
            });
        });
    </script>

<div id="editor">

</div>

<script type="text/javascript" src="__STATIC__/wangEditor/release/wangEditor.min.js"></script>
<script type="text/javascript">
    var E = window.wangEditor
    var editor = new E('#editor')
//        var editor = new E( document.getElementById('editor') )
    editor.customConfig.uploadImgHeaders = {
        'Accept': 'text/x-json'
    }
    // 配置服务器端地址
    editor.customConfig.uploadImgServer = '{:url("index/upload")}'
    editor.customConfig.uploadFileName = 'FileName';
    // 进行下文提到的其他配置
    // ……
    // ……
    // ……
    editor.customConfig.debug = location.href.indexOf('wangeditor_debug_mode=1') > 0
    editor.create()
</script>

<script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.js"></script>
<form action="index/upload" id="form-admin">
    <div style="">
        <!-- 加载编辑器的容器 -->
        <script id="container" type="text/plain"></script>
    </div>
        <input type="submit" value="submit">
</form>

<script>
    var ue = UE.getEditor('container');

    function isFocus(e) {
        alert(UE.getEditor('container').isFocus());
        UE.dom.domUtils.preventDefault(e)
    }

    function setblur(e) {
        UE.getEditor('container').blur();
        UE.dom.domUtils.preventDefault(e)
    }

    function insertHtml() {
        var value = prompt('插入html代码', '');
        UE.getEditor('container').execCommand('insertHtml', value)
    }

    function createEditor() {
        enableBtn();
        UE.getEditor('container');
    }
</script>
</body>
</html>